import { PropType } from 'vue';
import { comFileUploadRemindingApi } from '/@/api/config-center/model-design';
import type { UploadProps } from 'ant-design-vue';

type Direction = 'horizontal' | 'vertical';
export type StatusText = 'uploading' | 'done' | 'error' | null;
export type ProgressType = 'active' | 'success' | 'exception' | undefined;

export const BaseProps = {
  title: {
    type: String,
    default: '文件上传',
  },
  type: {
    type: String,
    default: 'file',
  },
  value: {
    type: Array as PropType<UploadProps['fileList']>,
    default: () => [],
  },
  accept: {
    type: [String, Array] as PropType<string | string[]>,
    default: () => ['.png', '.jpeg', '.jpg'],
  },

  // 上传大小
  maxSize: {
    type: Number,
    default: 5,
  },
  // 上传数量
  maxNumber: {
    type: Number,
    default: 1,
  },
  // 是否多选
  multiple: {
    type: Boolean,
    default: false,
  },
  // 上传api
  api: {
    type: Function as PropType<(params) => Promise<any>>,
    default: comFileUploadRemindingApi,
  },
  // // 是否拖拽
  dragger: {
    type: Boolean,
    default: true,
  },
  // 上传入参
  uploadParams: {
    type: Object as PropType<any>,
    default: () => ({}),
  },
  // 是否点击
  disabled: {
    type: Boolean,
    default: false,
  },

  // 上传数量达到上限后是否显示上传按钮
  showUploadIcon: {
    type: Boolean,
    default: true,
  },

  // 是否调用接口删除服务器文件
  delApi: {
    type: Function as PropType<PromiseFn>,
    default: null,
  },
  name: {
    type: String,
    default: '',
  },
  filename: {
    type: String,
    default: '',
  },
  valueField: {
    type: String,
    default: 'url',
  },
  downloadField: {
    type: String,
    default: 'url',
  },
  labelField: {
    type: String,
    default: 'fileName',
  },
  // 文件后缀
  suffixField: {
    type: String,
    default: 'fileName',
  },
  direction: {
    type: String as PropType<Direction>,
    default: 'horizontal',
  },
  isPreview: {
    type: Boolean,
    default: true,
  },
  isDownload: {
    type: Boolean,
    default: true,
  },
  // 是否显示文件名
  showFileName: {
    type: Boolean,
    default: true,
  },
  // change事件 是否只返回上传 成功的数据
  isBackSuccessData: {
    type: Boolean,
    default: true,
  },
};
